/*
 * Motor.h
 *
 *  Created on: 2023年12月22日
 *      Author: Administrator
 */

#ifndef MOTOR_H_
#define MOTOR_H_

//电机A引脚控制
#define DJA1_HIGH  		PB3 =1
#define DJA1_LOW   		PB3 =0
#define DJA2_HIGH  		PB2 =1
#define DJA2_LOW   		PB2 =0
#define DJA3_HIGH  		PB1 =1
#define DJA3_LOW   		PB1 =0
#define DJA4_HIGH  		PB0 =1
#define DJA4_LOW   		PB0 =0
//电机B引脚控制
#define DJB1_HIGH  		PC3 =1
#define DJB1_LOW  		PC3 =0
#define DJB2_HIGH  		PC2 =1
#define DJB2_LOW  		PC2 =0
#define DJB3_HIGH  		PC1 =1
#define DJB3_LOW  		PC1 =0
#define DJB4_HIGH  		PC0 =1
#define DJB4_LOW  		PC0 =0

typedef struct
{
    volatile uint8_t NowDir;         //当前位置
    volatile uint8_t TarGet;         //目标位置
    volatile uint8_t Step;           //要走的步数
    volatile unsigned Direction : 1;       //方向 1正， 0反
    volatile unsigned Beat : 3;       //需要的节拍数
}MotorStr;
extern MotorStr MotorA,MotorB;
extern uint8_t Motor_Flag;      //电机上电标志

void Motor_init(void);
void A_Rotate(uint8_t num);
void A_Change(uint8_t Now,uint8_t Target);
void Consume_AStep(void);
void B_Rotate(uint8_t num);
void B_Change(uint8_t Now,uint8_t Target);
void Consume_BStep(void);
void Motor_Move(void);
void Motor_Zero(void);
#endif /* MOTOR_H_ */
